=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 03-19-93 (21:00) Number: 116 From: QUINN TYLER JACKSON Refer#: NONE To: ALL Recvd: NO Subj: Formula Solver 1.4 5/ Conf: (35) Quick Basi --------------------------------------------------------------------------- >>> Continued from previous message ELSE ErrorCode = eqjDivisionByZero END IF CASE "?" ' random number from 0 to x, seed y RANDOMIZE y x = RND * x CASE "<<" ' bitshift left y by x bits x = INT(y) * 2 ^ INT(x) CASE ">>" ' bitshift right y by x bits x = INT(y) \ 2 ^ INT(x) CASE "!" ' factorial Temp& = 1 FOR i% = 1 TO x Temp& = Temp& * i% NEXT i% x = Temp& CASE "`" x = ABS(x) CASE "#" ' absolute x = INT(x) CASE "<" ' logical less than than x = x < y CASE "<=", "=<" ' logical less than or equal to x = x <= y CASE ">" ' logical greater than x = x > y CASE ">=", "=>" ' logical greater than or equal to x = x >= y CASE "==" ' logical equality x = x = y CASE "<>" ' logical inequality x = x <> y CASE "|=", "=|" ' logical implication x = x IMP y CASE "&=", "=&" ' logical equivlance x = x EQV y CASE "&" ' bitwise AND x = x AND y CASE "|" ' bitwise OR x = x OR y CASE "~" ' bitwise XOR x = x XOR y END SELECT END SUB SUB sqjAssignFun (FunctName$, Formula$, Protection%) FunctName$ = UCASE$(FunctName$) ParPtr% = INSTR(FunctName$, "[") NamePart$ = LEFT$(FunctName$, ParPtr% - 1) ParamPart$ = MID$(FunctName$, ParPtr% + 1, LEN(FunctName$) - ParPtr% -_ 1) ' First we see if this function is already in the list FOR i% = 1 TO SymPtr IF SymTable(i%).SymType = SymFUNCTION THEN IF RTRIM$(SymTable(i%).SymName) = NamePart$ THEN IF SymTable(i%).SymLvl <> PROTECTED THEN ' Since it was, just change its formula IF ParamPart$ <> "" THEN ' Make sure it just isn't a formula ' that uses empty parenthesis for the params. ParTable(SymTable(i%).TabPtr) = ParamPart$ END IF ELSE ErrorCode = eqjProtectedFunction END IF ForTable(SymTable(i%).TabPtr) = Formula$ EXIT SUB END IF END IF NEXT i% IF SymPtr < SYMMAX THEN ' Since it wasn't, put it there FunPtr = FunPtr + 1 SymPtr = SymPtr + 1 IF FunPtr <= FUNMAX THEN SymTable(SymPtr).SymName = NamePart$ SymTable(SymPtr).SymType = SymFUNCTION SymTable(SymPtr).SymLvl = Protection% SymTable(SymPtr).TabPtr = FunPtr ParTable(FunPtr) = ParamPart$ ForTable(FunPtr) = Formula$ ELSE ErrorCode = eqjFunctionTableFull END IF ELSE ErrorCode = eqjSymbolTableFull END IF END SUB SUB sqjAssignVar (VarName$, VarValue, Protection%) VarName$ = UCASE$(VarName$) ' First we see if this variable is already in the list FOR i% = 1 TO SymPtr IF SymTable(i%).SymType = SymVARIABLE THEN IF RTRIM$(SymTable(i%).SymName) = VarName$ THEN IF SymTable(i%).SymLvl <> PROTECTED THEN IF SymTable(i%).SymLvl = LvlPtr THEN ' Since it was, just change its value VarTable(SymTable(i%).TabPtr) = VarValue EXIT SUB END IF ELSE ErrorCode = eqjProtectedVariable EXIT SUB END IF END IF END IF NEXT i% IF SymPtr < SYMMAX THEN ' Since it wasn't, put it there VariPtr = VariPtr + 1 SymPtr = SymPtr + 1 IF VariPtr <= VARMAX THEN SymTable(SymPtr).SymName = VarName$ SymTable(SymPtr).SymType = SymVARIABLE SymTable(SymPtr).TabPtr = VariPtr SymTable(SymPtr).SymLvl = Protection% VarTable(VariPtr) = VarValue ELSE ErrorCode = eqjVariableTableFull END IF ELSE ErrorCode = eqjSymbolTableFull END IF END SUB SUB sqjDesParse (Phase%, x) SHARED TestDeep% ' This variable used for testing how deep recursion_ goes ' This is the central cortex of this module. ' It uses wicked recursion, so beware! In fact, this routine is so ' recursive that unless you're a major masochist, you'd better leave it ' well enough alone! TestDeep% = TestDeep% + 1 ' Used for testing phase only >>> Continued to next message * OLX 2.1 TD * A program is just a big bug that happened to work.... --- Maximus/2 2.01wb